package com.tcm.logistics.service.impl;

import com.base.core.pager.PageBean;
import com.base.core.pager.PageContext;
import com.tcm.logistics.dao.mapper.LogisticsDetailMapper;
import com.tcm.logistics.entity.LogisticsDetail;
import com.tcm.logistics.service.LogisticsDetailService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "0.0.1-alpha")
public class LogisticsDetailServiceImpl implements LogisticsDetailService {

    @Autowired
    private LogisticsDetailMapper logisticsDetailMapper;
    /**
     * 物流信息
     *
     * @param start
     * @param pagesize
     * @return
     */
    @Override
    public PageBean<LogisticsDetail> listPage(Long start, Long pagesize) {
        List<LogisticsDetail> logisticsDetailList = logisticsDetailMapper.listLogisticsDetail(start,pagesize);
        PageBean<LogisticsDetail> logisticsDetailPageBean = new PageBean<LogisticsDetail>(logisticsDetailList,
                PageContext.getDataCount(), start,pagesize);
        return logisticsDetailPageBean;
    }

    /**
     * 获得物流信息
     *
     * @param id
     * @return
     */
    @Override
    public LogisticsDetail findById(Long id) {
        return logisticsDetailMapper.findByKey(id);
    }

    /**
     * 新增物流信息
     *
     * @param logisticsDetail
     */
    @Override
    public void create(LogisticsDetail logisticsDetail) {
        logisticsDetailMapper.insert(logisticsDetail);
    }

    /**
     * 更新物流信息
     *
     * @param logisticsDetail
     */
    @Override
    public void update(LogisticsDetail logisticsDetail) {
        logisticsDetailMapper.updateByKey(logisticsDetail);
    }

    /**
     * 逻辑删除物流信息
     *
     * @param id
     * @return
     */
    @Override
    public int deleteLogicById(Long id) {
        return logisticsDetailMapper.deleteLogicByKey(id);
    }

    /**
     * 删除物流信息
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Long id) {
        return logisticsDetailMapper.deleteByKey(id);
    }
}
